package com.ftg.elvis.mapper;

import com.ftg.elvis.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface AdminBrandMapper {

	@Select("select * from brand where bname like concat('%', #{arg2}, '%') limit #{arg0}, #{arg1}")
	List<Brand> showAll(int page, int limit, String bname);

	@Select("select count(*) from brand where bname like concat('%', #{arg0}, '%')")
	int getCount(String bname);

	@Delete("delete from brand where bid = #{bid}")
	int delete(String bid);

	@Update("update brand set " +
			"btel = #{btel}, " +
			"baddress = #{baddress}, " +
			"bcategory = #{bcategory}, " +
			"bheat = #{bheat}, " +
			"enjoy = #{enjoy}, " +
			"username = #{username}, " +
			"email = #{email} " +
			"where bid = #{bid}" )
	int updateBrand(Brand brand);

	@Delete("delete from product where bid = #{bid}")
	void deleteProduct(String bid);
}
